<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<t:wrapper title="${title} ${course.name}">
	<jsp:body>
		<a href="javascript:history.back();">&laquo; <spring:message code="content.general.back"/></a>
		
		<h1>${course.name}</h1>
		<p class="price"><b><spring:message code="course.price"/></b> <spring:message code="content.general.currency"/>${course.price}</p>
		<b><spring:message code="course.description.title"/></b>
		<div id="course-description">${course.description}</div>
		<c:choose>
			<c:when test="${isLoggedIn}">
				<c:choose>
					<c:when test="${hasSubscribed}">
						<!-- Show chapters -->
						<c:forEach items="${course.chapters}" var="chapter">
							<h3>${chapter.title}</h3>
							<div>${chapter.content}<br />
							<a href="<c:url value="/progress_test/do_test/${chapter.progressTest.id}/"/> "><spring:message code="progresstest.link.do" /></a></div>
						</c:forEach>
						<button onclick="location.href='<c:url value="/course/${course.id}/forum"/>'"><spring:message code="course.forumlink"/></button>
					</c:when>
					<c:otherwise>
						<!-- Show subscribe button -->
						<button onclick="location.href='<c:url value="/course/subscribe/${course.id}"/>'"><spring:message code="course.button.subscribe"/></button>
					</c:otherwise>
				</c:choose>
			</c:when>
			<c:otherwise>
				<!-- Not logged in. Show demo content -->
				<c:forEach items="${demoChapters}" var="chapter">
					<h3>${chapter.title}</h3>
					<div>${chapter.content}</div>
				</c:forEach>
			</c:otherwise>
		</c:choose>
		<button onclick="location.href='<c:url value="/course/${course.id}/forum"/>'"><spring:message code="course.forumlink"/></button>
	</jsp:body>
</t:wrapper>